package com.commerceE.dao.impl;

import com.commerceE.common.dao.GenericIBatisDaoImpl;
import com.commerceE.dao.UserDao;
import com.commerceE.domain.User;

public class UserDaoImpl extends GenericIBatisDaoImpl<User> implements UserDao {

	@Override
	public String getNAMESPACE() {
		return User.class.getName();
	}
	
	public int countUserByUsername(String username){
		return getSqlSession().selectOne(getNAMESPACE() + ".countByUsername",username);
	}
	
	public int countUserByEmail(String username){
		return getSqlSession().selectOne(getNAMESPACE() + ".countByEmail",username);
	}
	
	public User getUserByUsernameAndPassword(String username, String password){
		User user = new User();
		user.setUsername(username);
		user.setPassword(password);
		return getSqlSession().selectOne(getNAMESPACE() + ".getUserByUsernameAndPassword",user);
	}
}
